# 使用官方.NET SDK镜像作为构建环境
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src

# 复制项目文件并恢复依赖
COPY src/MCPP.Net/*.csproj ./src/MCPP.Net/
RUN dotnet restore "src/MCPP.Net/MCPP.Net.csproj"

# 复制所有源代码
COPY . .

# 构建项目
WORKDIR "/src/src/MCPP.Net"
RUN dotnet build "MCPP.Net.csproj" -c Release -o /app/build

# 发布项目
FROM build AS publish
RUN dotnet publish "MCPP.Net.csproj" -c Release -o /app/publish

# 使用运行时镜像
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final
WORKDIR /app
COPY --from=publish /app/publish .

# 设置环境变量
ENV ASPNETCORE_URLS=http://+:80
EXPOSE 80

# 设置入口点
ENTRYPOINT ["dotnet", "MCPP.Net.dll","--urls=http://0.0.0.0:80"]